/**
 * @author 重写commonPath
 */
define(
		[],
		function() {

			return {
				// 富文本框工具栏菜单
				'wangEditorMenus' : [ 'head', // 标题
				'bold', // 粗体
				'fontSize', // 字号
				'fontName', // 字体
				'italic', // 斜体
				'underline', // 下划线
				'strikeThrough', // 删除线
				'foreColor', // 文字颜色
				'backColor', // 背景颜色
				'link', // 插入链接
				'list', // 列表
				'justify', // 对齐方式
				'quote', // 引用
				'emoticon', // 表情
				// 'image', // 插入图片
				'table', // 表格
				// 'video', // 插入视频
				// 'code', // 插入代码
				'undo', // 撤销
				'redo' // 重复
				],
				getAgeByBirthday : function(strBirthday) {
					if (!strBirthday)
						return;
					var returnAge;
					var strBirthdayArr = strBirthday.split("-");
					var birthYear = strBirthdayArr[0];
					var birthMonth = strBirthdayArr[1];
					var birthDay = strBirthdayArr[2];

					d = new Date();
					var nowYear = d.getFullYear();
					var nowMonth = d.getMonth() + 1;
					var nowDay = d.getDate();

					if (nowYear == birthYear) {
						returnAge = 0;// 同年 则为0岁
					} else {
						var ageDiff = nowYear - birthYear; // 年之差
						if (ageDiff > 0) {
							if (nowMonth == birthMonth) {
								var dayDiff = nowDay - birthDay;// 日之差
								if (dayDiff < 0) {
									returnAge = ageDiff - 1;
								} else {
									returnAge = ageDiff;
								}
							} else {
								var monthDiff = nowMonth - birthMonth;// 月之差
								if (monthDiff < 0) {
									returnAge = ageDiff - 1;
								} else {
									returnAge = ageDiff;
								}
							}
						} else {
							returnAge = -1;// 返回-1 表示出生日期输入错误 晚于今天
						}
					}
					return returnAge;// 返回周岁年龄
				},
				getAgeById : function(identityCard) {
					if (!identityCard)
						return;
					var len = (identityCard + "").length;
					if (len == 0) {
						return 0;
					} else {
						if ((len != 15) && (len != 18))// 身份证号码只能为15位或18位其它不合法
						{
							return 0;
						}
					}
					var strBirthday = "";
					if (len == 18)// 处理18位的身份证号码从号码中得到生日和性别代码
					{
						strBirthday = identityCard.substr(6, 4) + "/"
								+ identityCard.substr(10, 2) + "/"
								+ identityCard.substr(12, 2);
					}
					if (len == 15) {
						strBirthday = "19" + identityCard.substr(6, 2) + "/"
								+ identityCard.substr(8, 2) + "/"
								+ identityCard.substr(10, 2);
					}
					// 时间字符串里，必须是“/”
					var birthDate = new Date(strBirthday);
					var nowDateTime = new Date();
					var age = nowDateTime.getFullYear()
							- birthDate.getFullYear();
					// 再考虑月、天的因素;.getMonth()获取的是从0开始的，这里进行比较，不需要加1
					if (nowDateTime.getMonth() < birthDate.getMonth()
							|| (nowDateTime.getMonth() == birthDate.getMonth() && nowDateTime
									.getDate() < birthDate.getDate())) {
						age--;
					}
					return age;
				},
				getBirthdayFromIdCard : function(idCard) {
					if (!idCard)
						return;
					var birthday = "";
					if (idCard != null && idCard != "") {
						if (idCard.length == 15) {
							birthday = "19" + idCard.substr(6, 6);
						} else if (idCard.length == 18) {
							birthday = idCard.substr(6, 8);
						}

						birthday = birthday.replace(/(.{4})(.{2})/, "$1-$2-");
					}

					return birthday;
				},
				getDayByDateRange : function(startDate, enDate) {
					var sArr = startDate.split("-"), eArr = enDate.split("-"), sRDate = 0, eRDate = 0;

					sRDate = new Date(sArr[0], sArr[1], sArr[2]);
					eRDate = new Date(eArr[0], eArr[1], eArr[2]);
					return (eRDate - sRDate) / (24 * 60 * 60 * 1000);
				},
				addDate : function(date, days) {
					if (days == undefined || days === '') {
						days = 1;
					}
					var date = new Date(date);
					date.setDate(date.getDate() + days);
					var month = date.getMonth() + 1;
					var day = date.getDate();
					var mm = "'" + month + "'";
					var dd = "'" + day + "'";

					// 单位数前面加0
					if (mm.length == 3) {
						month = "0" + month;
					}
					if (dd.length == 3) {
						day = "0" + day;
					}

					var time = date.getFullYear() + "-" + month + "-" + day
					return time;
				}
			};
		});
